$(function(){
});

/**
 * 弹出图片浏览器,显示当前点击的图片
 * pid : 图片id
 */
function showPswp(pid){
    // 设置相对位置
    var top = $(window).scrollTop();
    $('.pswp').css('top',top);
    $(".pswp").fadeIn("slow");
    setTimeout(function(){
    $('body').css('overflow','hidden');
    },800);
    var url = "https://www.sinalma.cn/index/album/pswpPics/pid/"+pid;
    
    $.ajax({
    	url:url,
    	type:"get",
    	dataType:"json",
    	success:function(pics){
            $(".pswp_container").empty();
    		var htmlArr = new Array()
    		// 加载三张图片到图片浏览器
    		for (var i = 0; i < pics.length; i++) {
                if(i!=1){continue};
    		    curPids.push(pics[i]['pic_id']);
	            htmlArr.push("<div class='pswp_item'>");
	            htmlArr.push("<div class='pswp_zoom'>");
	            htmlArr.push("<img class='pswp_img_placeholder' src='"+pics[i]['small_link']+"'>");
	            htmlArr.push("<img class='pwsp_img' src='"+pics[i]['link']+"'>");
	            htmlArr.push("</div>");
	            htmlArr.push("</div>");
        	}

        	var htmlStr = htmlArr.join("");
        	$(".pswp_container").append(htmlStr);
            $('.pswp_item img').animate({
                opacity:'1',
                width:'70%',
                left:'15%',
                top:'20%'
            });
    	},
    	error:function(){
    		console.log('error');
    	}
    })
}
var curPids = new Array();
// 当图片切换时调用此方法,重新排列
function changePic(){
    
}

function nextPic(){

}

function prevPic(){
    
}

function pswpClose(){
    $('body').css('overflow','auto');
    // setTimeout(function(){
    $(".pswp").fadeOut("slow");
    // },500);
}
// glyphicon glyphicon-zoom-out
function pswpFull(){
    fullScreen();
}
// glyphicon glyphicon-resize-small
function pswpGlass(){

}
function fullScreen() {
    var elem = document.body;
    if (elem.webkitRequestFullScreen) {
        elem.webkitRequestFullScreen();
    } else if (elem.mozRequestFullScreen) {
        elem.mozRequestFullScreen();
    } else if (elem.requestFullScreen) {
        elem.requestFullscreen();
    } else {
        notice.notice_show("浏览器不支持全屏API或已被禁用", null, null, null, true, true);
    }
}
function exitFullScreen() {
    var elem = document;
    if (elem.webkitCancelFullScreen) {
        elem.webkitCancelFullScreen();
    } else if (elem.mozCancelFullScreen) {
        elem.mozCancelFullScreen();
    } else if (elem.cancelFullScreen) {
        elem.cancelFullScreen();
    } else if (elem.exitFullscreen) {
        elem.exitFullscreen();
    } else {
        notice.notice_show("浏览器不支持全屏API或已被禁用", null, null, null, true, true);
    }
}